﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false">
            <table id="dg1" style="display: none;">
                <thead>
                    <tr>
                        <th data-options="field:'ID',checkbox:true"></th>
                        <th data-options="field: 'Name',width: 200">名称</th>
                    </tr>
                </thead>
            </table>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {

            $.InvokeAjax({
                url: "Api/V1/System/GetListJurisdictionUserInfoAll",
                data: { JurisdictionID: $.getUrlParamer("JurisdictionID") },
                callBack: function (data) {
                    var arr = $.StrToJson(data).Results;
                    $('#dg1').datagrid({
                        fit: true,
                        border: false,
                        data: arr
                    });
                    DataBind();
                }
            });
        });


        function DataBind() {

            $.InvokeAjax({
                url: "Api/V1/System/GetListJurisdictionUserInfo",
                data: {  UserInfoID: $.getUrlParamer("UserInfoID") },
                callBack: function (data) {
                    var arr = $.StrToJson(data).Results;
                    var rows = $('#dg1').datagrid('getRows');
                    if (rows.length > 0) {
                        $.each(rows, function (i, e) {
                            if (isCon(arr, e["ID"])) {
                                $('#dg1').datagrid('selectRow', i);
                            }
                        });
                    }
                }
            });
        }

        function isCon(arr, val) {
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].ID == val)
                    return true;
            }
            return false;
        }


        $("#buttonOk").click(function () {
            var arr = [];
            var rows = $('#dg1').datagrid('getSelections');
            //if (rows.length > 0) {
            $.each(rows, function (i, e) {
                arr.push({ ID: e["ID"] });
            });


            $.InvokeAjax({
                url: "Api/V1/System/AddJurisdictionUserInfo",
                data: { UserInfoID: $.getUrlParamer("UserInfoID"), JurisdictionList: arr },
                callBack: function (data) {
                    alert("修改权限成功");
                    $.DialogClose(true);
                }
            });
            //}
            //else {
            //    $.messager.alert('删除操作', '您还没有选择任何记录！', 'info');
            //}
        });

    </script>

</asp:Content>
<%--未调整--%>